Last Updated: 2023-01-16

References: FLAC 8.1 Manual: User's Guide; Command Reference; Fish in FLAC

This tutorial will go through the steps in executing a model analysis in FLAC. You will end up simulating 1D compression with the mohr-coulomb model.

What you'll learn

This tutorial does not discuss building a FLAC model or writing FISH scripts. These will come in future classes!

FLAC

You can use FLAC on your personal windows computer. Here is a link to the download - you must be logged into your pdx.edu account:

FLAC 8.1 download

You can also access FLAC remotely through CEE computer labs. FLAC is installed on computers for the MCECS windows remote lab.

MCECS windows remote connections

FISH in FLAC

Throughout this course, you will be editing FISH scripts. You may find it worthwhile to work in Notepad++ with a FISH user-defined language plugin that highlights text. This will make editing and troubleshooting your scripts much, much easier.

First, download Notepad++. Then download the FISH plugin here courtesy of the PM4Sand website (Boulanger & Ziotopoulou):

FISH plugin download for notepad++

The plugin can be placed in a hidden folder on your computer: Username\AppData\Roaming\Notepad++

Now a flac option should appear in the language tab in Notepad++.

Open FLAC

Open the FLAC 8.1 GUI. The command window will pop up, and you will likely need to press c to continue in demonstration mode.

The FLAC graphic user interface (GUI) should appear on your screen along with the Model Options dialog box.

Select SI: meter-megagram-second from the System of physical units dropdown menu and press OK.

The Project File save window should pop up. Select the yellow file icon and navigate to your desired project directory (maybe in your directory for this class). Save under your desired project name (e.g., 410_1d_comp_intro.prj).

You should see the main GUI window for your FLAC project. We will do most of our work from the Console tab. The Model window can be used to watch the model's progress and to track simulated history variables.

Obtain FISH file

Place a FISH file into the same directory as the FLAC project. For this tutorial, we will use the file 1d_compr_mc.fis. You can download the file here:

1d_compr_mc.fis

Open the file in notepad++ (or the text editor of your choice). The script includes FLAC commands and user-defined functions that define the model simulation; the lines of the script are read and carried out by FLAC. There are also some comments that start with ";", these lines are ignored by FLAC. I have used these comments throughout the script as explainers - I suggest you take some time to read through the script and familiarize yourself with it.

Once you get more comfortable with FISH and FLAC, you will be able to edit these files and create your own.

Call the FISH file

Call the FISH script by either:

The model should start cycling! This simulates 1D compression loading and unloading with a linear elastic soil model.

Now that the model analysis has completed, we can look at the model results and model history. In this class, we will generally be looking at displacement (strains), stresses, and porewater pressures.

The model results can be looked at in terms of:

If you look at the model tab the geometry should appear. If it appears blank, try selecting the refresh button on the right-hand side. This is the model geometry - this model is a single element.

Values when the simulation stops

This can be useful to get final results (e.g., what is the final displacement due to loading?), or to verify that the model is behaving as intended (e.g., did stress values initialize properly? did model properties get assigned as intended?).

To look at these values use the FLAC command print, followed by the variable you want to look at, and the index of the zone or gridpoint.

There is a table provided at the end of this section with some of the values you may want to print.

Simulation history values

FLAC histories store data values throughout the simulation so that you can see how these progress throughout the simulation. To track history values, you need to (1) tell FLAC which variables to track, and (2) tell FLAC how often to store them. These are specified to FLAC by commands in the FISH file.

Tracking history variables

The simulation that you just ran tracked several history values. These variables were tracked in lines 96 to 127 of the script.

hist is the command to FLAC to store the history variable. The number that follows hist tells FLAC which number the history variable is indexed to (e.g., unbalanced force is indexed to 2).

nstep tells FLAC to store the history values every 1000 calculation timesteps (nstep = 1000). This only needs to be designated once. If nothing is designated then a default value will be assigned.

View simulation history results

You can view the simulation histories within the GUI. Select the Plot and then History options at the top menu.

A history plot dialogue should appear. Enter "Unbal Force" in the Name line. Highlight 2 line [Max. unbal. force] in the Item ID column. Check the Versus box above the right column. Highlight 1 [Dynamic time] in the right column. Then press OK.

You should now see a plot of the unbalanced force vs simulation time in the GUI with a tab called "Unbal Force".

This is a plot of the unbalanced gridpoint force throughout the simulation time. Notice a couple of things here:

Create similar history plots that are appropriately labelled for:

You should now have several history tabs to examine the simulation results.

Export history data

Throughout the course you will need to export these history data to make figures. The FLAC figures are fine for checking your simulation results, but they are not great for presenting the results in assignments or reports.

There are two options for exporting history data: copy data from history plots or using FLAC commands to export history data.

Option 1: Copy data from history plots

This option uses the history plots that you just created. With one of those plots open in the GUI, right click on the plot and select View data. A dialog box should appear with the data that make up the plot, you can choose to select and copy the data, or use the export to CSV... option.

Option 2: Export data through FLAC commands

This option is useful when you have a lot of history variables to export across many different simulations.

Enter these commands into the flac: command line:

set hisfile file_name.his (press enter)

history write 101 102 103 104 vs 301 (press enter)

Now the .his file will appear in the same file directory as the FLAC project.

You can set whatever filename works for you. The .his extension signifies that these are files that contain history data. The numbers are indexed to the history variable as discussed at the beginning of this section. For this example, the history data are exported as total stresses vs. axial strain.

Now that the simulation is complete, you should save it so you can later restore it and continue working with it. There are three things that we will look at here:

Save model state

Saving a model state creates a .sav file with all of your model data. By saving this state you can later restore the model.

To save the model state, type in the flac: command line:

save 1d_compr_final.sav and press enter

Now you should see the .sav file in the same directory as your model script and project.

Save project file

Saving the project file creates a .prj file with the history plots that you created. Saving project files can save you a lot of time since you don't have to re-create those plots every time you open a new project.

To save the model project, select File then Save project.

Restore model state

Restoring a model state will bring up a previous simulation state.

In the flac: command line, type new and press enter. This will clear all the model data.

In the flac: command line, type restore 1d_compr_final.sav and press enter. Now the model state should be restored.

This is a reference table for FLAC variables that you may want to track throughout simulations in this class. An exhaustive list is in the FLAC Manual, but these are the variables most relevant for this class. There are two tables: one for values stored at gridpoints and one for values stored in the model zone.

Model gridpoint variables

FLAC reference

Description

x

x coordinate value

y

y coordinate value

xdisp

Displacement in the x direction

ydisp

Displacement in the y direction

xvel

Velocity in the x direction

yvel

Velocity in the y direction

xacc

Acceleration in the x direction

yacc

Acceleration in the y direction

gpp

Porewater pressures stored at gridpoints

xr

Reaction force in the x direction

yr

Reaction force in the y direction

Model zone variables

FLAC reference

Description

sxx*

Normal total stress in the x direction for the zone

syy*

Normal total stress in the y direction for the zone

szz*

Normal total stress in the z direction (out of plane direction) for the zone

sxy*

Shear stress for the zone

esxx*

Effective stress in the x-direction

esyy*

Effective stress in the y-direction

eszz*

Effective stress in the z-direction

pp

Porewater pressure for the zone (averaged from gridpoint porewater pressures)

density

Mass density

sig1

Major principal stress in the xy plane

sig2

Minor principal stress in the xy plane

sdif

Principal stress difference (sig1 - sig2)

ssi

Shear strain (found from displacements)

vsi

Volumetric strain (accumulated increment)

*you can also print these for subzones with asxx, bsxx, csxx, dsxx, etc.

*remember - compressive stresses are negative in FLAC!

1d_compr_mc.fis

; File Name: 1D_compr_mc.fis
; Author: Diane Moug
; Original Date: 7-January-2019
; Last Edit: 7-January-2019
; Description: Single element compression test. 1-D compression test with 
; Mohr-Coulomb constitutive model (linear elastic-perfectly plastic)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; model configuration;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
config dynamic                 ;; the "config" command must be the first line of all FLAC models
                                        ;; in this case we are configuring the model to be able to run dynamic, uncoupled mechanical analyses (no groundwater seepage analysis)
                                        ;; the geometry is plane-strain by default

set large                        ;; updates model coordinates with calculated displacements (large-strain Lagrangian analysis) 
set echo on                        ;; useful for seeing model progress in the GUI, can be turned off when model is running smoothly
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; initialize model zones and geometry
grid 1 1                        ;; initializes a 1x1 model (1 model zone with 4 gridpoints)
                                        ;; default coordinates will be 0,0;0,1;1,1;1,0
model mohr-coulomb        ;; a model type must be specified for each model zone
                                        ;; this assigns the model zone the Mohr-Coulomb constitutive model
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                        

;; model properties;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
def $soil_properties                ;;this is a FISH function
                        
        $void_ratio = 1.2        ;[]
        $rho_water = 1.                ;[Mg/m^3]
        $Gs = 2.5                        ;[],rho_solids/rho_water (specific gravity of solids)
        $bulk_modulus = 10000.                ;[kPa], elastic bulk modulus
        $poissons_ratio = 0.3                ;[], Poisson's ratio
        $cohesion = 60.                                ;[kPa], cohesion
        $dilation = 0.                                ;[kPa], dilation angle
        $friction = 30.                                ;[degrees], soil friction angle for Mohr-Coulomb failure envelope
        $tension = 0.                                ;[kPa], tension soil strength
        
        ;;calculate the elastic shear modulus (G) from assigned $bulk_modulus and poisson's ratio
        $shear_modulus = (3.*$bulk_modulus*(1.-(2.*$poissons_ratio)))/(2.*(1.+$poissons_ratio))                ;[kPa], elastic shear modulus (G)
        
        ;;calculate the bulk density from specific gravity, water density, and void ratio
        $rho_total = ($Gs*$water_rho+($void_ratio))/(1.+$void_ratio)                        ;Mg/m^3
        
        command                        ;; brings us out of the FISH language and back into FLAC commands 
                prop bulk_mod        $bulk_modulus                        ;[kpa], elastic bulk modulus 
                prop shear_mod        $shear_modulus                        ; [kPa], elastic shear modulus
                prop dens                $rho_total                                ;[Mg/m^3], mass density
                prop cohesion        $cohesion
                prop dil                $dilation
                prop fric                $friction        ;degrees
                
        end_command         ;; end the FLAC commands

end                                ;;this is the end of the FISH function
$soil_properties                ;;user-defined routine that defines and assigns soil properties
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; problem definition;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define $problem_definition
        $sigma_y_ini = -10.                 ;[kPa], y-direction normal total stress (note is FLAC stresses < 0 are compression, stresses > 0 are tension)
        $sigma_x_ini = -10.                ;[kPa], x-direction normal total stress

        $sigma_y_final = -200.                ;[kPa], final y-direction stress 
        
        $Ho = 0.5*((y(1,2)-y(1,1))+(y(2,2)-y(2,1)))                ;[m], initial zone height
end
$problem_definition                ;;user-defined routine that defines the initial conditions and loading rate

ini syy $sigma_y_ini         ;; command to initialize model with y-direction stress
ini sxx $sigma_x_ini        ;; command to initialize model with x-direction stress
ini szz $sigma_x_ini        ;; command to initialize model with x-direction stress
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        
        
;; boundary conditions;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set boundary conditions for 1-D compression loading
fix x y j=1                ;; command to fix movement in x and y-direction on "base-plate"
fix x j=2                ;; command to fix movement in the x-direction for 1-D compression
apply syy $sigma_y_ini i=1,2 j=2        ;; apply "seating load" at the top of the element
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; dynamic damping conditions;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
set dy_damping rayleigh 0.005 100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; user-defined routines for strain calculations
define $strains
        
        $delta_y = 0.5*(ydisp(1,2)+ydisp(2,2))                ;[m], displacement in y-direction
        $eps_axial = $delta_y/$Ho                                        ;[], axial strain
end
$strains

;; define histories;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; histories track variables such as stress-strain path
hist 1 nstep = 1000 dytime                ;; number histories so that they remain referenced to that number, otherwise they are referenced in that order
                                                                ;; nstep is the number of timesteps a history is recorded, if it is too small the data file will be very large
                                                                ;; if it is very large then sample points will be too far apart
hist 2 unbal

                                                                
hist 101 sxx i=1 j=1                        ;; there is only one zone in this model, so all zone histories will default to zone (1,1)
hist 102 syy i=1 j=1
hist 103 szz i=1 j=1
hist 104 sxy i=1 j=1

hist 201 xdisp i=1 j=1                        ;; x-displacement is a gridpoint property, therefore must specify which gridpoint history is recorded at
hist 202 xdisp i=2 j=1
hist 203 xdisp i=1 j=2
hist 204 xdisp i=2 j=2

hist 205 ydisp i=1 j=1
hist 206 ydisp i=2 j=1
hist 207 ydisp i=1 j=2
hist 208 ydisp i=2 j=2

hist 209 xvel i=1 j=1
hist 210 xvel i=2 j=1
hist 211 xvel i=1 j=2
hist 212 xvel i=2 j=2

hist 213 yvel i=1 j=1
hist 214 yvel i=2 j=1
hist 215 yvel i=1 j=2
hist 216 yvel i=2 j=2

hist 300 $strains
hist 301 $eps_axial
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
solve dytime 10.                ;seconds
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
def $load_cycle
        $solve_time = 400.0                         ;[seconds]
        $int = 2000                                        ;[], number of solve intervals
        $t_int = $solve_time/$int        ;[seconds]
        $t_solve = dytime
        
        $delta_sigma_y = $sigma_y_final - $sigma_y_ini
        $delta_sigma_y = $delta_sigma_y/$int
        $vertical_applied_stress = $sigma_y_ini
        
        loop $k (1,$int)
                $vertical_applied_stress = $vertical_applied_stress + $delta_sigma_y
                command
                        app syy $vertical_applied_stress i=1,2 j=2
                        solve dytime $t_solve
                end_command
                
                $t_solve = $t_solve + $t_int
        end_loop
end
$load_cycle
step 10000

def $unload_cycle
        $solve_time = 400.0                         ;[seconds]
        $int = 2000                                        ;[], number of solve intervals
        $t_int = $solve_time/$int        ;[seconds]
        $t_solve = dytime
        $vertical_applied_stress = syy(1,1)

        $delta_sigma_y = $sigma_y_final - $sigma_y_ini
        $delta_sigma_y = $delta_sigma_y/$int
        
        loop $k (1,$int)
                $vertical_applied_stress = $vertical_applied_stress - $delta_sigma_y
                command
                        app syy $vertical_applied_stress i=1,2 j=2
                        solve dytime $t_solve
                end_command
                
                $t_solve = $t_solve + $t_int
        end_loop
end
$unload_cycle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

step 10000